package com.test.springquickstart.controller;

import com.test.springquickstart.pojo.People;
import com.test.springquickstart.service.PeopleService;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@RestController
public class MyController {
    @Autowired
    private PeopleService peopleService;

    @RequestMapping(value = "/getPeople", method = {GET})
    public String testFroPost(@NotNull Integer id) {
        People people = peopleService.getPeopleById(id);
        if (people == null) {
            return "cannot find id : " + id + " in db";
        }
        return people.toString();
    }
}
